package com.my.listeners;

import com.sun.org.apache.xml.internal.serializer.ToStream;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
import java.io.Serializable;

public class BeanListener implements HttpSessionActivationListener, Serializable {
    private int num;
    private String name;
    @Override
    public void sessionWillPassivate(HttpSessionEvent httpSessionEvent) {
        System.out.println("即将钝化之前：BeanListener对象会随着session的钝化而钝化");
    }

    @Override
    public void sessionDidActivate(HttpSessionEvent httpSessionEvent) {
        System.out.println("活化之后：BeanListener对象会随着session的活化而活化");
    }

    @Override
    public String toString() {
        return "Bean：" + name + " " + num;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
